package com.mystudy.dataStructure.head;

import com.mystudy.dataStructure.queue.Queue;

/**
 * @program: infoalgorithm
 * @description: 优先队列:使用最大堆实现
 * @author: zhouzhilong
 * @create: 2019-08-06 15:57
 **/
public class PriorityQueue<E extends Comparable> implements Queue<E> {
    private MaxHeap<E> maxHeap;


    public PriorityQueue() {
        this.maxHeap = new MaxHeap<>();
    }

    @Override
    public void enqueue(E e) {
        maxHeap.add(e);
    }

    @Override
    public E dequeue() {
        return maxHeap.extractMax();
    }

    @Override
    public E getFront() {
        return maxHeap.findMax();
    }

    @Override
    public int getSize() {
        return maxHeap.size();
    }

    @Override
    public boolean isEmpty() {
        return maxHeap.isEmpth();
    }
}
